//package org.mspring.mlog.security;
//
//import org.springframework.security.access.AccessDeniedException;
//import org.springframework.security.access.ConfigAttribute;
//import org.springframework.security.authentication.InsufficientAuthenticationException;
//import org.springframework.security.core.Authentication;
//import org.springframework.security.core.GrantedAuthority;
//import org.springframework.stereotype.Component;
//
//import java.util.Collection;
//import java.util.Iterator;
//
///**
// * @author Gao Youbo
// * @since 2013-1-11
// */
//@Component("accessDecisionManager")
//public class DefaultAccessDecisionManager implements org.springframework.security.access.AccessDecisionManager {
//
//    @Override
//    public void decide(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes) throws AccessDeniedException, InsufficientAuthenticationException {
//        // 所请求的资源拥有的权限(一个资源对多个权限)
//        Iterator<ConfigAttribute> iterator = configAttributes.iterator();
//        while (iterator.hasNext()) {
//            ConfigAttribute configAttribute = iterator.next();
//            String needPermission = configAttribute.getAttribute();
//            for (GrantedAuthority ga : authentication.getAuthorities()) {
//                if (needPermission.equals(ga.getAuthority())) {
//                    return;
//                }
//            }
//        }
//        throw new AccessDeniedException(" 没有权限访问！ " + object);
//    }
//
//    @Override
//    public boolean supports(ConfigAttribute attribute) {
//        return true;
//    }
//
//    @Override
//    public boolean supports(Class<?> clazz) {
//        return true;
//    }
//}
